﻿<%@ Page Title="Thống kê tin nhắn MT" Language="C#" MasterPageFile="~/App_MasterPages/Aquarius.Master"
    AutoEventWireup="true" CodeBehind="SmsMtStatistics.aspx.cs" Inherits="PanasonicWarranty.UI.SmsMtStatistics"
    EnableEventValidation="false"  %>

<%@ Register Src="../UserControl/ucPaging.ascx" TagName="ucPaging" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CssContent" runat="server">
    <style type="text/css">
        #searching span
        {
            width: 160px;
            display: inline-block;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            DatePicker("txtFromDate,txtToDate");
            ComboBox("ddlAgency");
        });
        function CheckSearch() {
            var fromTime = $("[id$=txtFromDate]").datepicker('getDate');
            var toTime = $("[id$=txtToDate]").datepicker('getDate');
            if (fromTime == null || toTime == null) {
                $("#ltrCheckSearch").html("Bắt buộc chọn thời điểm đầu và thời điểm cuối");
                return false;
            }
            else {
                if (toTime < fromTime) {
                    $("#ltrCheckSearch").html("Thời điểm cuối không được nhỏ hơn thời điểm đầu");
                    return false;
                }
                fromTime.setMonth(fromTime.getMonth() + 3);
                if (fromTime < toTime) {
                    $("#ltrCheckSearch").html("Giới hạn khoảng tìm kiếm là 3 tháng");
                    return false;
                }
            }
            $("#ltrCheckSearch").html("");
            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div class="row-fluid">
        <div class="span12">
            <div class="head">
                <div class="isw-grid">
                </div>
                <h1>
                    Điều kiện tìm kiếm</h1>
                <div class="clear">
                </div>
            </div>
            <div class="block-fluid" style="padding: 10px 0px 5px 10px">
                <table cellpadding="0" width="100%">
                    <tbody>
                        <tr>
                            <td>Sender name</td>
                            <td>
                                <asp:DropDownList ID="ddlShortCode" runat="server">
                                    <asp:ListItem Value="" Text="" />
                                    <asp:ListItem Value="8050" Text="8050" />
                                    <asp:ListItem Value="Panasonic" Text="Panasonic" />
                                </asp:DropDownList>
                            </td>
                            <td> Số điện thoại</td>
                            <td><asp:TextBox ID="txtPhoneNumber" runat="server" /></td>
                        </tr>
                        <tr>
                            <td> Thời gian gửi</td>
                            <td><asp:TextBox ID="txtFromDate" runat="server" /></td>
                            <td> đến ngày</td>
                            <td>
                                <asp:TextBox ID="txtToDate" runat="server" />
                                <span style="color:Red"> (Khoảng tìm kiếm tối đa 3 tháng)</span>
                            </td>
                        </tr>
                        <tr>
                            <td>Trạng thái tin nhắn</td>
                            <td>
                                <asp:DropDownList ID="ddlStatus" runat="server">
                                    <asp:ListItem Value="" Text="" />
                                    <asp:ListItem Value="SENT" Text="SENT" />
                                    <asp:ListItem Value="PENDING" Text="PENDING" />
                                    <asp:ListItem Value="ERROR" Text="ERROR" />
                                    <asp:ListItem Value="FAIL" Text="FAIL" />
                                </asp:DropDownList>
                            </td>
                            <td>Đại lý</td>
                            <td><asp:DropDownList ID="ddlAgency" runat="server" /></td>
                        </tr>
                    </tbody>
                </table>
                <div style="text-align: center">
                    <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" OnClick="btnSearch_Click"
                        CssClass="btn" OnClientClick="return CheckSearch();" />
                </div>
                <div style="text-align: center; color: Red">
                    <span id="ltrCheckSearch"></span>
                </div>
            </div>
        </div>
    </div>
    <asp:UpdatePanel ID="udpn" runat="server">
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
        </Triggers>
        <ContentTemplate>
            <div class="row-fluid">
                <div class="span12">
                    <div class="head">
                        <div class="isw-grid">
                        </div>
                        <h1>
                            Thống kê</h1>
                        <div class="clear">
                        </div>
                    </div>
                    <div class="block-fluid table-sorting">
                        <div role="grid" class="dataTables_wrapper" id="tSortable_wrapper">
                            <div class="dataTables_length">
                                <label>
                                    Hiển thị
                                    <asp:DropDownList ID="tSortable_length" size="1" aria-controls="tSortable" runat="server"
                                        OnSelectedIndexChanged="tSortable_length_SelectedIndexChanged" AutoPostBack="true" onchange="if(!CheckSearch()) return false;">
                                        <asp:ListItem Value="50" Selected="True">50</asp:ListItem>
                                        <asp:ListItem Value="100">100</asp:ListItem>
										<asp:ListItem Value="150">150</asp:ListItem>
										<asp:ListItem Value="200">200</asp:ListItem>
										<asp:ListItem Value="300">300</asp:ListItem>
                                    </asp:DropDownList>
                                    dòng</label>
                            </div>
                            <div>
                                <uc1:ucPaging ID="pagingtop" runat="server"  Visible="false"/>
                            </div>
                            <asp:GridView ID="grvData" runat="server" CssClass="dataTables_wrapper table2 dataTable" aria-describedby="tSortable_info"
                                AutoGenerateColumns="false" ShowHeaderWhenEmpty="true">
                                <Columns>
                                    <asp:TemplateField HeaderText="STT" ItemStyle-CssClass="STT">
                                        <ItemTemplate>
                                            <%#(Container.DataItemIndex + 1) + (pagingtop.CurrentPage - 1) * pagingtop.PageSize%>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField HeaderText="Sender name" DataField="ShortCode" ItemStyle-CssClass="Phone"/>
                                    <asp:BoundField HeaderText="Số điện thoại" DataField="DestAddr" ItemStyle-CssClass="Phone"/>
                                    <asp:TemplateField HeaderText="Đại lý" ItemStyle-CssClass="width4">
                                        <ItemTemplate>
                                            <%#pa_Agency.GetAgencyName(Eval("AgencyID"))%>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField HeaderText="Tin nhắn" DataField="Message" />
                                    <asp:TemplateField HeaderText="Độ dài mẫu tin" ItemStyle-CssClass="DateTime">
                                        <ItemTemplate>
                                            <%#Eval("Message").ToString().GetMessageCount()%>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField HeaderText="Thời gian gửi" DataField="SentTime" DataFormatString="{0:dd/MM/yyyy HH:mm:ss}" ItemStyle-CssClass="DateTime2"/>
                                    <asp:BoundField HeaderText="Trạng thái tin nhắn" DataField="Status" ItemStyle-Wrap="false" ItemStyle-CssClass="width1"/>
                                </Columns>
                            </asp:GridView>
                            <div class="dataTables_info" id="tSortable_info">
                                <asp:Literal ID="ltrInfo" runat="server" />
                            </div>
                            <div class="dataTables_paginate paging_full_numbers" id="tSortable_paginate">
                                <uc1:ucPaging ID="pagingbottom" runat="server"  Visible="false"/>
                            </div>
                        </div>
                        <div class="clear">
                        </div>
                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="udprogress" DisplayAfter="1" runat="server">
        <ProgressTemplate>
            <div class="ui-widget-overlay ui-front">
                <img src='<%=ResolveUrl("~/images/loading.gif")%>' alt="Loading..." style="position: fixed; top: 50%;
                    left: 50%" />
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</asp:Content>
